package com.example.helper2;

import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.fragment.app.DialogFragment;

public class fragment_card_show_rumour extends DialogFragment {
    private TextView title;
    private TextView date;
    private TextView abstractText;

    private TextView testView;

    // 根据传递的值进行查找
    private int id;

    // 数据库的处理方式
    private SQLiteDatabase sqL_read;

    // 获得查找到的卡片信息
    private RumourCardInfo cardInfo;


    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        Bundle bundle = getArguments();
        if (bundle != null) {
            id = bundle.getInt("id");
        }

        View view = inflater.inflate(R.layout.dialogview, container, false);

        title = view.findViewById(R.id.dialog_title);
        date = view.findViewById(R.id.dialog_type);

        abstractText = view.findViewById(R.id.dialog_content);

        rumour_card_database cards = new rumour_card_database(getActivity());
        sqL_read = cards.getReadableDatabase();
        cardInfo = cards.querydatabyid(sqL_read, id);

        title.setText(id + ". " + cardInfo.getTitle());
        date.setText(cardInfo.getDate());
        abstractText.setText(cardInfo.getAbstractText());

        return view;
    }
}
